package com.wms.service.impl;

import com.wms.entity.RoleResource;
import com.wms.mapper.RoleResourceMapper;
import com.wms.service.RoleResourceService;
import io.jsonwebtoken.lang.Assert;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class RoleResourceServiceImpl extends BaseServiceImpl<RoleResourceMapper, RoleResource> implements RoleResourceService {

    @Resource
    private RoleResourceMapper roleResourceMapper;

    @Override
    public void deleteByRoleId(Long roleId) {
        Assert.notNull(roleId);
        roleResourceMapper.deleteByRoleId(roleId);
    }

    @Override
    public void deleteByRoleIds(List<Long> roleIds) {
        Assert.notEmpty(roleIds);
        roleResourceMapper.deleteByRoleIds(roleIds);
    }

    @Override
    public Boolean isExist(RoleResource roleResource) {
        Assert.notNull(roleResource);
        return roleResourceMapper.isExist(roleResource);
    }

    @Override
    public List<Long> findResourceIdsByRoleId(Long roleId) {
        Assert.notNull(roleId);
        return roleResourceMapper.findResourceIdsByRoleId(roleId);
    }
}
